package com.simpou.commons.model;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlTransient;
import lombok.Delegate;

/**
 * Modelo identificável concreto.
 *
 * @author Jonas Pereira
 * @since 2013-06-30
 * @version 2013-06-30
 */
public abstract class AbstractIdentifiableModel<T extends Serializable>
        extends AbstractModel
        implements IdentifiableModel<T> {

    @Delegate
    private final IdentifiableModelDelegate<T> identifiableModel;

    public AbstractIdentifiableModel(Class<T> clasz) {
        this.identifiableModel = new IdentifiableModelDelegate<T>(clasz);
    }

    @XmlTransient
    public T getid() {
        return identifiableModel.identity();
    }

    @Override
    public final boolean equals(Object obj) {
        return identifiableModel.equals(this, obj);
    }

    @Override
    public final int hashCode() {
        return identifiableModel.hashCode();
    }
}
